package io;

import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

public class PWTest1 {
    public static void main(String[] args) throws IOException {
        Scanner scanner = new Scanner(System.in);
        FileOutputStream fos = new FileOutputStream("pw.txt",true);

        //转换输出流(字符流,高级流):1负责衔接字节与字符流 2负责将写出的字符转换成字节
        OutputStreamWriter osw = new OutputStreamWriter(fos);
        //缓冲字符输出流(字符流,高级流),负责块写文本数据加速
        BufferedWriter bw = new BufferedWriter(osw);
        //PrintWriter(字符流,高级流):1按行写出字符串 2自动行刷新
        PrintWriter pw = new PrintWriter(bw,true);
        while (true) {
            String line = scanner.nextLine();
            if ("exit".equals(line)){
                break;
            }
            pw.println(line);
        }
        System.out.println("再见");
        pw.close();
    }
}
